package com.example.lx6_4.xq

import androidx.lifecycle.MutableLiveData
import com.example.base.db.OrderDao
import com.example.base.entity.OrderEntityItem
import com.example.base.mvvm.BaseViewModel
import com.example.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class XqViewModel @Inject constructor(val apiService: ApiService,val orderDao: OrderDao) : BaseViewModel() {

    val xqData = MutableLiveData<OrderEntityItem>()

    fun getXq(id:Int){
        httpRequest({apiService.getOrderId(id)},xqData::postValue)
    }

    val upData = MutableLiveData<OrderEntityItem>()

    fun getUpData(id:Int,body:Any){
        httpRequest({apiService.getUpData(id,toBody(body))},upData::postValue)
    }

    val upRoom = MutableLiveData<Int>()

    fun getUpRoom(body: OrderEntityItem){
        httpRoom({orderDao.getUpdateOrder(body)},upRoom::postValue)
    }

}